% 
% @(#)phoney_String.m	1.2  3/4/88
%
export _StringObject to "Builtins"

const _StringObject == immutable object _StringObject
  export getSignature, create, literal

  const StringType == immutable type StringType
    function getElement [index : Integer] -> [e : Character]
    function getSlice [lb : Integer, length : Integer] -> [a : String]
    function || [o : String] -> [r : String]
      % r <- self || o
    function asString -> [r : String]
      % r <- self
    function > [o : String] -> [r : Boolean]
      % r <- self > o
    function >= [o : String] -> [r : Boolean]
      % r <- self >= o
    function < [o : String] -> [r : Boolean]
      % r <- self < o
    function <= [o : String] -> [r : Boolean]
      % r <- self <= o
    function = [o : String] -> [r : Boolean]
      % r <- self = o
    function != [o : String] -> [r : Boolean]
      % r <- self != o
    function length -> [ r : Integer ]
    operation lowlevelsleazysetelement [Integer, Character]
  end StringType
  function getSignature -> [result : Signature]
    result <- StringType
  end getSignature
  
  function literal [rep : Any, offset : Integer, length : Integer]
    -> [result : StringType]
    result <- self.create[length]
  end literal
  function create [length : Integer] -> [result : StringType]
    result <- immutable object aString
      export getElement, getSlice, ||, asString, >, >=, <, <=, =, !=, length,
        lowlevelsleazysetelement

      function getElement [index : Integer] -> [e : Character]
	primitive 011 [e] <- [index]
      end getElement
      function getSlice [lb : Integer, length : Integer] -> [a : String]
	primitive 111 [a] <- [lb, length]
      end getSlice
      function || [o : String] -> [r : String]
	primitive 211 [r] <- [o]
      end ||
      function asString -> [r : String]
	primitive 311 [r] <- []
      end asString
      function > [o : String] -> [r : Boolean]
	primitive 411 [r] <- [o]
      end >
      function >= [o : String] -> [r : Boolean]
	primitive 511 [r] <- [o]
      end >=
      function < [o : String] -> [r : Boolean]
	primitive 611 [r] <- [o]
      end <
      function <= [o : String] -> [r : Boolean]
	primitive 711 [r] <- [o]
      end <=
      function = [o : String] -> [r : Boolean]
	primitive 811 [r] <- [o]
      end =
      function != [o : String] -> [r : Boolean]
	primitive 911 [r] <- [o]
      end !=
      function length -> [ r : Integer ]
	primitive 1011 [r] <- []
      end length
      operation lowlevelsleazysetelement [i : Integer, c : Character]
	primitive 1111 [] <- [i, c]
      end lowlevelsleazysetelement
    end aString
  end create
end _StringObject
